package com.sharding.jdbc.controller;

import com.sharding.jdbc.bean.User;
import com.sharding.jdbc.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * description: UserController
 * date: 2020/5/5 0005 9:19
 * author: xiayz
 * version: 1.0
 */
@Controller
@RequestMapping("userController")
public class UserController {
    @Resource
    UserService userService;

    @RequestMapping("saveUser")
    public void saveUser(User user){
        try{
            userService.save(user);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    @RequestMapping("findUser")
    @ResponseBody
    public User findUser(Long id){
        User user = userService.get(id);
        return user;
    }
}
